package seismosurfer.event;

import java.awt.event.MouseEvent;

import seismosurfer.layer.SeismoLayer;

import com.bbn.openmap.event.MapMouseEvent;
import com.bbn.openmap.layer.OMGraphicHandlerLayer;
import com.bbn.openmap.omGraphics.OMGraphic;
import com.bbn.openmap.omGraphics.event.StandardMapMouseInterpreter;
import com.bbn.openmap.util.Debug;

/**
 * An extension to the StandardMapMouseInterpreter. Handles
 * mouse events on the SeismoLayer(s).
 *
 */
public class SeismoMapMouseInterpreter extends StandardMapMouseInterpreter {

    public SeismoMapMouseInterpreter() {
        super();
    }

    public SeismoMapMouseInterpreter(OMGraphicHandlerLayer l) {
        super(l);
    }
    
    public boolean rightClick(OMGraphic omg, MouseEvent me) {

        if (grp instanceof SeismoLayer && me instanceof MapMouseEvent) {

            return displayPopup(((SeismoLayer) grp).getItemsForOMGraphicMenu(
                    omg, (MapMouseEvent) me), me);

        }

        return displayPopup(grp.getItemsForOMGraphicMenu(omg), me);
    }

    public boolean leftClick(OMGraphic omg, MouseEvent me) {
        if (DEBUG) {
            Debug.output("leftClick(" + omg.getClass().getName() + ") at "
                    + me.getX() + ", " + me.getY());
        }

        if (grp instanceof SeismoLayer && me instanceof MapMouseEvent) {
            return ((SeismoLayer) grp).leftClick(omg, (MapMouseEvent) me);
        }

        return true;
    }

}
